<template>
	<view>
		<uni-list>
			<uni-list-item showArrow title="修改密码" clickable @click="goTo('../changePassword/changePassword')" />
			<uni-list-item showArrow title="意见反馈" clickable @click="goTo('../suggestion/suggestion')" />
			<uni-list-item :rightText="phone" title="联系客服" clickable @click="TakePhone(phone)" />
			<!-- #ifdef APP-PLUS -->
			<uni-list-item title="检查更新" />
			<!-- #endif -->
		</uni-list>
		<button class="customer-btn" @click="logout()">退出登录</button>
	</view>
</template>

<script>
	import {
		logout,
		querySystemConfig
	} from "@/api/user.js";
	import permision from "@/js_sdk/wa-permission/permission.js";
	export default {
		data() {
			return {
				phone:''
			};
		},
		onLoad(){
			this.querySystemConfig({
				"categoryId": "1",
				"configId": "CRM_PHONE"
			})
			
		},
		onPullDownRefresh() {
			this.querySystemConfig({
				"categoryId": "1",
				"configId": "CRM_PHONE"
			})
		},
		methods: {
			async logout() {
				const res = await logout()
				if (res.success) {
					uni.showToast({
						title: "账号已登出！"
					})
					setTimeout(() => {
						this.goTo('../../login/login')
					}, 500)
				}
			},
			async querySystemConfig(options) {
				const res = await querySystemConfig(options)
				if (res.success) {
					this.phone = res.returnObj[0].configValue
				}
			},
			goTo(e) {
				var url = e;
				uni.navigateTo({
					url: url
				})
			},
			TakePhone(e) {
				permision.requestAndroidPermission('android.permission.CALL_PHONE').then((res)=>{
					console.log("authres",res)
					if(res == 1){
						uni.makePhoneCall({
							phoneNumber: e
						});
					}else{
						permision.gotoAppPermissionSetting()
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}

	.customer-btn {
		background-color: #00B5DD !important;
		color: #fff;
		position: fixed;
		bottom: 30rpx;
		left: 30rpx;
		right: 30rpx;
		border-radius: 8px;
		height: 44px;
		line-height: 44px;
		font-size: 32rpx;
		font-weight: 500;
	}
</style>